﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace King.Box.Models.Util
{
    public class ResponseData
    {
        public bool Result { get; set; }
        public string Message { get; set; }

        public static ResponseData Failtrue(string msg)
        {
            return new ResponseData()
            {
                Result = false,
                Message = msg
            };
        }

        public static ResponseData Success(string msg = null)
        {
            var response = new ResponseData()
            {
                Result = true
            };

            if (!string.IsNullOrEmpty(msg))
                response.Message = msg;

            return response;
        }
    }

    public class ResponseData<T> : ResponseData where T : class, new()
    {
        public T Data { get; set; }

        public new static ResponseData<T> Failtrue(string msg)
        {
            return new ResponseData<T>()
            {
                Result = false,
                Message = msg,
                Data = default(T)
            };
        }

        public static ResponseData<T> Success(T val, string msg = null)
        {
            var response = new ResponseData<T>()
            {
                Result = true,
                Data = val
            };

            if (!string.IsNullOrEmpty(msg))
                response.Message = msg;

            return response;
        }
    }
}
